﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.Rules
{
    /// <summary>
    /// Check if the author made last comment and there are post from other people
    /// </summary>
    class AuthorMadeLastComment_Rule : IRule
    {
        public double apply(SiteEnum site, QuestionInformation info)
        {
            if (info.Replies.Count == 0) return 0;
            if (info.Replies[info.Replies.Count - 1].Author != info.Question.Author) return 0;
            foreach (var reply in info.Replies)
            {
                if (reply.Author != info.Question.Author) return 1;
            }
            return 0;
        }

        public string RuleName
        {
            get { return "AuthorMadeLastComment_Rule"; }
        }
    }
}
